<div>
  <div class="main-title">
    <h2>用户管理</h2>
  </div>
  <div class="main-section">
    <a href="{:url('edit')}" class="btn btn-success">+ 新增</a>
  </div>
  <div class="main-section">
    <table class="table table-striped table-bordered table-hover">
      <thead>
        <tr>
          <th>用户名</th>
          <th>所属角色</th>
          <th width="162">创建时间</th>
          <th width="162">更新时间</th>
          <th width="120">操作</th>
        </tr>
      </thead>
      <tbody>
        {foreach $user as $v}
        <tr>
          <td><a href="{:url('edit', ['id' => $v.id])}">{$v.username}</a></td>
          <td><a href="{:url('admin.permission/index', ['admin_role_id' => $v.admin_role_id])}"
              class="j-menu-to">{$v.admin_role.name}</a></td>
          <td>{$v.create_time}</td>
          <td>{$v.update_time ?: '-'}</td>
          <td>
            <a href="{:url('edit', ['id' => $v.id])}" style="margin-right:5px;">编辑</a>
            <a href="{:url('delete', ['id' => $v.id])}" class="j-del text-danger">删除</a>
          </td>
        </tr>
        {/foreach}
        {if $user->isEmpty()}
        <tr>
          <td colspan="5" class="text-center">还没有添加项目</td>
        </tr>
        {/if}
      </tbody>
    </table>
  </div>
</div>
<script>
  $('.j-del').click(function () {
    if (confirm('您确定要删除此项？')) {
      main.ajaxPost($(this).attr('href'), function () {
        main.contentRefresh();
      });
    }
    return false;
  });
  $('.j-menu-to').click(function () {
    main.content($(this).attr('href'), function () {
      main.menuActive('admin.permission');
    });
    return false;
  });
</script>